package com.fhao.java_gobang.config;

import com.fhao.java_gobang.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@Slf4j
@ControllerAdvice
@ResponseBody
public class ExceptionAdvice {
    @ExceptionHandler
    public Result handle(Exception e) {
        log.info("发生异常, e: "+e);
        return Result.fail("内部错误,请联系管理员");
    }

    public Result handle (NullPointerException e) {
        log.info("发生异常, e: "+e);
        return Result.fail("内部错误,请联系管理员");
    }
}
